﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    Periodical journal = ViewBag.Journal;
    ViewBag.Title = "稿件中心 - " + journal.Name;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<div id="content-header">
    <h1>
        最新稿件</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/magazine/index" class="tip-bottom"><i class="icon-home"></i>起始页</a> <a href="javascript:"
        class="current">最新稿件</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="alert alert-info">
                <button type="button" class="close" data-dismiss="alert">
                    &times;</button>
                <strong>注：</strong>如果您误删稿件，请联系管理员处理。
            </div>
            <div class="widget-box" style="margin-top: 0px;">
                <div class="widget-title">
                    <h5>
                        最新稿件</h5>
                </div>
                <div class="widget-content nopadding">
                    <table class="table table-bordered">
                        <thead>
                            <tr style="cursor: pointer;">
                                <th>
                                    标题
                                </th>
                                <th style="width: 13%">
                                    作者
                                </th>
                                <th style="width: 20%">
                                    稿件状态 
                                </th>
                                <th style="width: 20%">
                                    稿件范围
                                </th>
                                <th style="width: 10%">
                                    来稿时间
                                </th>
                                <th style="width: 17%">
                                    操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @{
                                ItemListBox<Article> data = ViewBag.Article;
                                if (data.Data != null && data.Data.Any())
                                {
                                    foreach (var item in data.Data)
                                    {
                                <tr>
                                    <td>
                                        <a href="/workspace/magazine/articledetail/@item.Id">@item.Title</a>
                                    </td>
                                    <td style="text-align: center">
                                        @{string authors = string.Empty;
                                          item.ArticleAuthor.ForEach(
                                          c => { authors += c.AuthorName + "，"; });
                                          authors = authors.Trim();
                                          authors = authors.Remove(authors.Length - 1); }
                                        @authors
                                    </td>
                                    <td style="text-align: center">
                                        @item.Status.Mapping()
                                    </td>
                                    <td style="text-align: center">
                                        <span title="@item.GJFW.Replace(";", "，")">@item.GJFW.Replace(";", "，")</span>
                                    </td>
                                    <td style="text-align: center">
                                        @item.CreateTime.ToString("yyyy-MM-dd")
                                    </td>
                                    <td style="text-align: center">
                                        @if (item.IsDelete)
                                        {
                                            <i>稿件已删除</i>
                                        }
                                        else
                                        {
                                            if (item.Status == ArticleStatus.Open)
                                            {
                                                <a href="#myshenchaBox" onclick="doShenChaFinish(@item.Id)" data-toggle="modal" class="btn btn-primary btn-mini">
                                                    审查</a>
                                            }
                                            if(item.Status == ArticleStatus.Revise)
                                            {
                                                <a onclick="complete(@item.Id)" class="btn btn-primary btn-mini">
                                                    编辑校对完成</a>
                                            }
                                            if(item.Status == ArticleStatus.Complete)
                                            {
                                                <a onclick="isPublish(@item.Id)" class="btn btn-primary btn-mini">
                                                    已出版</a>
                                            }
                                            <a href="/workspace/magazine/articledetail/@item.Id" class="btn btn-success btn-mini">
                                                查看</a>
                                            <a href="javascript:" class="btn btn-danger btn-mini" onclick="cancelarticle(@item.Id)">
                                                删除</a>
                                        }
                                    </td>
                                </tr>
                                    }
                                }
                            }
                        </tbody>
                    </table>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
<div id="myshenchaBox" class="modal hide" style="display: none;" aria-hidden="true">
    <div class="modal-header">
        <button data-dismiss="modal" class="close" type="button">
            ×</button>
        <h3>
            验收结果</h3>
    </div>
    <form id="zsfinishform" class="form-horizontal" action="/workspace/magazine/magazineexamine"
    method="post">
    <input type="hidden" name="articleId" id="hidscarticleId" />
    <div class="modal-body">
        <div class="widget-content">
            <div class="control-group">
                <label class="control-label" style="width: 80px;">
                    验收结果</label>
                <div class="controls" style="margin-left: 110px;">
                    <select id="sltzsres" name="result" onchange="zschangeexamineresult(this)">
                        <option value="0" selected="selected">录用</option>
                        <option value="9">审核不通过</option>
                    </select>
                </div>
            </div>
            <div id="reszsmsgbox" class="control-group" style="display: none;">
                <label class="control-label" style="width: 80px;">
                    审核意见</label>
                <div class="controls" style="margin-left: 110px;">
                    <textarea id="tarzsmsg" name="msg" rows="6" cols="20"></textarea>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <input type="submit" class="btn btn-primary" value="确定" />
        <a data-dismiss="modal" class="btn" href="javascript:;">取消</a>
    </div>
    </form>
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#likarticle').addClass('open active');
        });
        function cancelarticle(id) {
            if (confirm('确认删除此稿件吗？')) {
                window.location.href = "/workspace/magazine/CancelArticle/" + id + "?group=@ViewBag.Group";
            }
        }
        function doShenChaFinish(id) {
            $('#hidscarticleId').val(id);
        }
        function zschangeexamineresult(sender) {
            if ($(sender).val() == 0) {
                $('#reszsmsgbox').hide();
            }
            else {
                $('#reszsmsgbox').show();
            }
        }
        function complete(id) {
            if(confirm('确认已经编辑校对完成?')){
                window.location.href = "/workspace/magazine/examinecomplete/" + id + "?group=@ViewBag.Group";
            }
        }
        function isPublish(id) {
            if (confirm('确认已经出版?')) {
                window.location.href = "/workspace/magazine/IsPublish/" + id + "?group=@ViewBag.Group";
            }
        }
    </script>
}
